ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Handling errors
  • Carriage Return at the end of line
  • Position in the file
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Writes a block of bytes to an external file.
Caution: The added elements are not inserted into the external file but they overwrite the existing elements.
Example
Syntax

Writing a block of bytes into an external file Hide the details

<Result> = <File used>.Write(<Block to write> [, <Size to write>])
<Result>: Integer
  • Number of bytes written to the file.
  • -1 if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
<File used>: DiskFile variable
Name of the DiskFile variable initialized with .Open or Create.
<Block to write>: Character string
Block of bytes to must be written to the file (up to 2 GB).
The format of the block of bytes is respected. No conversion is performed.
<Size to write>: Optional integer
Size of the string to write (in bytes).
Remarks

Handling errors

<DiskFile variable>.Write throws an error in the following cases:
  • the file is not opened,
  • the file is not accessible in write mode,
  • the file is locked by another computer or by another application,
  • no disk space is available.

Carriage Return at the end of line

<DiskFile variable>.WriteLine is used to automatically insert a carriage return (CR) at the end of the added line. To insert a Carriage Return (CR) with <DiskFile variable>.Write, simply use the CR constant.
For example:
MyFile is DiskFile
...
ResEcriture = MyFile.Ecrit("Compte-rendu" + CR + "Ventes de mars 2021")

Position in the file

When opening a file, the current position corresponds to:
  • the first file byte (by default),
  • the last byte of the file is the file is opened in "addition" mode (foAdd constant).
This position can be modified by <DiskFile variable>.Seek.
<DiskFile variable>.Write writes the specified elements from the current position. Once <DiskFile variable>.Write has been executed, the current position is set to the last byte written.
Remark: To always read the start, you must call <DiskFile variable>.Seek and then <DiskFile variable>.Read.
Business / UI classification: Business Logic
Component: wd290std.dll
Minimum version required
  • Version 28
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 11/21/2023

Send a report | Local help